Skip to content

refactor vmcall-raw send/receive, reject invalid VMM responses#867

Merged
sgrams merged 3 commits into
intel:mainfrom
haitaohuang:upstream/pr1-trivial-fixes
Jun 8, 2026
Merged

refactor vmcall-raw send/receive, reject invalid VMM responses#867
sgrams merged 3 commits into
intel:mainfrom
haitaohuang:upstream/pr1-trivial-fixes

Conversation

@haitaohuang

Copy link
Copy Markdown
Contributor

No description provided.

@haitaohuang haitaohuang requested review from jyao1 and sgrams as code owners May 29, 2026 16:49
@agokarn

agokarn commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Changes look good

Comment thread src/devices/vmcall_raw/src/transport/vmcall.rs Outdated
haitaohuang and others added 3 commits June 5, 2026 16:36
Extract the duplicated poll logic from vmcall_service_migtd_send
and vmcall_service_migtd_receive into poll_vmcall_completion().

The shared function handles: interrupt flag check, data_status
parsing, flag consumption after final status, and success/error
determination. Each caller only adds its operation-specific logic
(send returns data_length, receive copies payload to private Vec).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
A hostile VMM can complete a tdvmcall_migtd_receive with
status=VMM_SUCCESS but data_length=0. The previous implementation let
this propagate as Ok(0) through VmcallRaw::recv, which would stall the
caller's read loop indefinitely (no forward progress, no error).

Reject zero-length success inside the receive poll_fn closure with
VmcallRawError::Malformed, which surfaces to upstream callers as a
network error instead of an infinite spin.

Also stop relying on the post-completion data_length on the send path
(per spec, data_length is owned by MigTD when status=0 and is not a
meaningful VMM-reported value after completion). The previously
returned value was already discarded by VmcallRaw::send, so this is a
no-op in behavior but makes the spec contract explicit. Document this
in the poll_vmcall_completion doc comment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
When the migration context has been destroyed (no entry in
VMCALL_MIG_CONTEXT_FLAGS for the request id), any interrupt injection
from the VMM should be rejected. Previously the else branch discarded
the error with `let _ = ...`, allowing execution to fall through and
treat DMA buffer contents as a valid VMM response.

Return an error immediately so the caller rejects the stale injection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Haitao Huang <haitaohuang@microsoft.com>
@haitaohuang haitaohuang force-pushed the upstream/pr1-trivial-fixes branch from 295aa0b to 9570b40 Compare June 5, 2026 16:36
@sgrams sgrams merged commit c917306 into intel:main Jun 8, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants